﻿using Project.API.Models.Member;
using Project.BLL.MemberBll;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace Project.API.Controllers.MemberContrllers
{
    public class MemberRelatedController : ApiController
    {
        // GET api/<controller>
        [HttpGet]
        [Route("api/Goods/Related")]
        public ResultData<List<RelatedDto>> Get()
        {
           RelatedBll bll=new RelatedBll();

            ResultData<List<RelatedDto>> list = new ResultData<List<RelatedDto>>();

            list.data = bll.Query().GroupBy(s => s.MemberType.Mtype).Select(x => new RelatedDto {
                Mtype =x.Key,
                Rname=x.Select(a=>a.MembershipRights.Rname).ToList()
            }).ToList();
            
            return list;
        }

        // GET api/<controller>/5
        public bool Get(int id)
        {
            //升级会员
            var data = new MemberBll().Query().Where(x => x.user_info.user_id == id).FirstOrDefault();
            data.Mid += 1;
            bool bol = new MemberBll().Update(data);
            return bol;
        }

        // POST api/<controller>
        public void Post([FromBody] string value)
        {
        }

        // PUT api/<controller>/5
        public void Put(int id, [FromBody] string value)
        {
        }

        // DELETE api/<controller>/5
        public void Delete(int id)
        {
        }
    }
}